package cn.dengl.sky.springboot.common.config.security;

import cn.dengl.sky.springboot.sys.entity.User;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

/**
 * @program: springboot
 * @description: 获取用户信息
 * @author: dengl
 * @create: 2018-12-19 09:20
 */
@Component
public class AuthenticationFacade implements  IAuthenticationFacade {
    @Override
    public Authentication getAuthentication() {
        return SecurityContextHolder.getContext().getAuthentication();
    }

    @Override
    public User getUser() {
        return (User)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    }
}
